package com.ftg.learn.lesson3;

/**
 * 游戏
 *
 * @author kangjx
 * @version 1.0
 * @date 2023/6/7 下午2:18
 */
public class HomeWork02 {

    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) {
            int cpu1 = (int) (Math.random() * 3) + 1;
            int cpu2 = (int) (Math.random() * 3) + 1;

            String cpu1Value = "";
            switch (cpu1) {
                case 1:
                    cpu1Value = "剪子";
                    break;
                case 2:
                    cpu1Value = "石头";
                    break;
                default:
                    cpu1Value = "布";
            }

            String cpu2Value = "";
            switch (cpu2) {
                case 1:
                    cpu2Value = "剪子";
                    break;
                case 2:
                    cpu2Value = "石头";
                    break;
                default:
                    cpu2Value = "布";
            }

            if(cpu1 == cpu2){
                //格式化输出
                System.out.printf("cpu1输出的是%s,cpu2输出提%s,结果是平局\n",cpu1Value,cpu2Value);
            }else if(cpu1 != 3 && cpu1 > cpu2){
                System.out.printf("cpu1输出的是%s,cpu2输出提%s,结果是cpu1胜了\n",cpu1Value,cpu2Value);
            }else if(cpu1 == 3 && cpu2 == 1){
                System.out.printf("cpu1输出的是%s,cpu2输出提%s,结果是cpu2胜了\n",cpu1Value,cpu2Value);
            }else{
                System.out.printf("cpu1输出的是%s,cpu2输出提%s,结果是cpu2胜了\n",cpu1Value,cpu2Value);
            }
        }
    }

}
